class Solution {
public:
    int maxProduct(vector<string>& words) {
        int ans = 0;
        int n = words.size();
        int ma = 0;
        vector<int>f(n + 1);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < words[i].size(); j++) {
                int x = words[i][j] - 'a';
                f[i] |= (1 << x);
            }
        }
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                if ((f[i] & f[j]) == 0) {
                    int m = words[i].size() * words[j].size();
                    ma = max(ma, m);
                }
            }
        }
        return ma;
    }
};